package common.netty.client.handle.diapatcher;


import common.RpcResponse;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class RequestPendingCenter {

    private static Map<Long, OperationResultFuture> map = new ConcurrentHashMap<Long, OperationResultFuture>();

    public void add(Long streamId, OperationResultFuture future) {
        map.put(streamId, future);
    }

    public void set(Long streamId, RpcResponse operationResult) {
        OperationResultFuture operationResultFuture = map.get(streamId);
        if (operationResultFuture != null) {
            operationResultFuture.setSuccess(operationResult);
            map.remove(streamId);
        }
    }


}
